/*
 * Copyright 2004-2005 asoft
 * 本软件及其所有拷贝的名称，与光盘上或本软件中注明的公司同在。
 * 本软件及文档享有版权，并受国家版权法及国际协约条款的保护。
 * 您不可以从本软件中去掉其版权声明；并保证为本软件的拷贝（本部或部分）* 复制版权声明。
 * 您同意制止以任何形式非法拷贝本软件及文档。
 * 版权信息参见：
 *      http://www.asoft.cn/licenses
 */

package com.asoft.examonline.init;

import org.apache.log4j.Logger;

import com.asoft.common.base.util.PriUtils;
import com.asoft.common.basedata.define.TypeParams;
import com.asoft.common.basedata.manager.TypeManager;
import com.asoft.common.basedata.model.Type;
import com.asoft.common.sysframe.manager.OrgManager;
import com.asoft.common.sysframe.manager.PostManager;
import com.asoft.common.sysframe.manager.RoleManager;
import com.asoft.common.sysframe.manager.UserManager;
import com.asoft.common.sysframe.model.Org;
import com.asoft.common.sysframe.model.Post;
import com.asoft.common.sysframe.model.Role;
import com.asoft.common.sysframe.model.User;
import com.asoft.common.viewframe.define.ViewFrameParams;
import com.asoft.common.viewframe.manager.AreaManager;
import com.asoft.common.viewframe.manager.ColumnManager;
import com.asoft.common.viewframe.manager.HomeManager;
import com.asoft.common.viewframe.model.Area;
import com.asoft.common.viewframe.model.Column;
import com.asoft.common.viewframe.model.Home;
import com.asoft.examonline.define.DiffcultyCode;
import com.asoft.examonline.define.DomainCode;
import com.asoft.examonline.define.QuestionSourceCode;
import com.asoft.examonline.define.QuestionTypeCode;
import com.asoft.examonline.define.SubjectCode;


/**
 * 利用hibernate初始化数据库数据
 * 
 * @author amonlei
 *
 */
public class InitData
{
        static Logger logger = Logger.getLogger(InitData.class);
        
        private OrgManager orgManager;
        
        private RoleManager roleManager;
        
        private PostManager postManager;
        
        private UserManager userManager;
        
        private HomeManager homeManager;
        
        private AreaManager areaManager;
        
        private ColumnManager columnManager;
        
        private TypeManager typeManager;
        
        private int index;

        /**
         * @param orgManager 要设置的 orgManager。
         */
        public void setOrgManager(OrgManager orgManager)
        {
                this.orgManager = orgManager;
        }

        /**
         * @param postManager 要设置的 postManager。
         */
        public void setPostManager(PostManager postManager)
        {
                this.postManager = postManager;
        }

        /**
         * @param roleManager 要设置的 roleManager。
         */
        public void setRoleManager(RoleManager roleManager)
        {
                this.roleManager = roleManager;
        }
        
        /**
         * @param userManager 要设置的 userManager。
         */
        public void setUserManager(UserManager userManager)
        {
                this.userManager = userManager;
        }
        
        /**
         * @param areaManager 要设置的 areaManager。
         */
        public void setAreaManager(AreaManager areaManager)
        {
                this.areaManager = areaManager;
        }

        /**
         * @param columnManager 要设置的 columnManager。
         */
        public void setColumnManager(ColumnManager columnManager)
        {
                this.columnManager = columnManager;
        }

        /**
         * @param homeManager 要设置的 homeManager。
         */
        public void setHomeManager(HomeManager homeManager)
        {
                this.homeManager = homeManager;
        }
        
        /**
         * @param typeManager 要设置的 typeManager
         */
        public void setTypeManager(TypeManager typeManager)
        {
                this.typeManager = typeManager;
        }

        // 初始化db
        public void init()
        {
               logger.info("初始化数据库数据");
               if(this.userManager.getByAccount("admin") == null)
               {
                       User admin = this.initSys(1);
                       this.initBaseData(admin);
                       logger.debug("初始化完毕");
               }
               else
               {
                       logger.debug("已经初始化过");
               }
        }
        
        // 优先级
        public String getPri()
        {
                return PriUtils.value(this.index ++);
        }
        
        // 停止
        public void stop()
        {
                logger.info("初始化完毕");
        }
        
        // 系统管理初始化
        public User initSys(int index)
        {
                logger.info(index + ".1. 初始化sysframe的数据");
                // 机构
                logger.debug("初始化机构");
                Org hnnkzx = new Org("hnnkzx",
                                      "xx中学",
                                      this.getPri());
                this.orgManager.save(hnnkzx);
                logger.debug("保存" + hnnkzx.getName());
                
                Org jwkOrg = new Org("jwk",
                                      "教务科",
                                      this.getPri());
                jwkOrg.setSuperOrg(hnnkzx);
                this.orgManager.save(jwkOrg);
                logger.debug("保存" + jwkOrg.getName());
                
                // 角色
                logger.debug("初始化角色");
                Role userRole = new Role("user","用户",this.getPri());
                this.roleManager.save(userRole);
                logger.debug("保存" + userRole.getName());
                Role adminRole = new Role("admin","管理员",this.getPri());
                adminRole.setSuperRole(userRole);
                this.roleManager.save(adminRole);
                logger.debug("保存" + adminRole.getName());
                Role eqAdminRole = new Role("eqAdmin","试题管理员",this.getPri());
                eqAdminRole.setSuperRole(userRole);
                this.roleManager.save(eqAdminRole);
                logger.debug("保存" + eqAdminRole.getName());
                Role eqInputerRole = new Role("eqInputer","试题录入员",this.getPri());
                eqInputerRole.setSuperRole(userRole);
                this.roleManager.save(eqInputerRole);
                logger.debug("保存" + eqInputerRole.getName());
                
                // 岗位
                logger.debug("初始化岗位");
                Post hnnkzx_user_post = new Post(hnnkzx,userRole);
                this.postManager.save(hnnkzx_user_post);
                logger.debug("保存" + hnnkzx_user_post.getName());
                Post hnnkzx_admin_post = new Post(hnnkzx,adminRole);
                this.postManager.save(hnnkzx_admin_post);
                Post hnnkzx_eqadmin = new Post(hnnkzx,eqAdminRole);
                this.postManager.save(hnnkzx_eqadmin);
                logger.debug("保存" + hnnkzx_eqadmin.getName());
                Post hnnkzx_eqinputer = new Post(hnnkzx,eqInputerRole);
                this.postManager.save(hnnkzx_eqinputer);
                logger.debug("保存" + hnnkzx_eqinputer.getName());
                
                
                // 人员
                logger.debug("初始化人员");
                User admin = new User("admin",
                                      "管理",
                                      "员",
                                      this.getPri());
                admin.addPost(hnnkzx_admin_post,0);
                this.userManager.save(admin);
                logger.debug("保存" + admin.getName());
                
                logger.info(index + ".2. 初始化viewframe的数据");
                // 主页
                logger.debug("初始化主页");
                Home defaultHome = new Home(ViewFrameParams.DEFAULT_HOME,
                                     "默认",
                                     this.getPri());
                this.homeManager.save(defaultHome);
                
                // 分区
                logger.debug("初始化分区");
                Area funcColumnsArea = new Area(defaultHome,
                                         ViewFrameParams.DEFAULT_HOME_FUNC_AREA,
                                         "功能栏",
                                         this.getPri());
                this.areaManager.save(funcColumnsArea);
                
                // 栏目
                logger.debug("初始化栏目");
                Column basedataColumn = new Column(funcColumnsArea,
                                                   "",
                                                   "基础数据",
                                                   "",
                                                   this.getPri());
                this.columnManager.save(basedataColumn);
                  
                          Column typeColumn = new Column(basedataColumn,
                                                         "",
                                                         "类型",
                                                         "column_141_img.gif",
                                                         "moduleinfor/basedata/type/xtreeroot.jsp",
                                                         this.getPri());
                          this.columnManager.save(typeColumn);                
                Column moduleNameColumn = new Column(funcColumnsArea,
                                                    "",
                                                    "考试管理",
                                                    "",
                                                    this.getPri());
                   this.columnManager.save(moduleNameColumn);
                   
                           Column examQuestionColumn = new Column(moduleNameColumn,
                                                              "",
                                                              "试题管理",
                                                              "GongWuSQ_01.gif",
                                                              "moduleinfor/exammanager/examquestion/root.jsp",
                                                              this.getPri());
                           this.columnManager.save(examQuestionColumn);
                           
                Column personColumn = new Column(funcColumnsArea,
                                                 "",
                                                 "个人事务",
                                                 "",
                                                 this.getPri());
                this.columnManager.save(personColumn);
                
                        Column changepwColumn = new Column(personColumn,
                                                           "",
                                                           "修改密码",
                                                           "GongWuSQ_01.gif",
                                                           "moduleinfor/changepw/root.jsp",
                                                           this.getPri());
                        this.columnManager.save(changepwColumn);
                
                Column logColumn = new Column(funcColumnsArea,
                                              "",
                                              "日志管理",
                                              "",
                                              this.getPri());
                this.columnManager.save(logColumn);
                
                        Column ologColumn = new Column(logColumn,
                                                       "",
                                                       "操作日志",
                                                       "column_221_img.gif",
                                                       "moduleinfor/logs/operatinglog/xtreeroot.jsp",
                                                       this.getPri());
                        this.columnManager.save(ologColumn);
                
                Column sysColumn = new Column(funcColumnsArea,
                                              "",
                                              "系统管理",
                                              "",
                                              this.getPri());
                this.columnManager.save(sysColumn);
                
                        Column orgColumn = new Column(sysColumn,
                                                      "",
                                                      "机构管理",
                                                      "new_column_4.gif",
                                                      "moduleinfor/sysframe/org/root.jsp",
                                                      this.getPri());
                        this.columnManager.save(orgColumn);
                        
                        Column roleColumn = new Column(sysColumn,
                                                       "",
                                                       "角色管理",
                                                       "column_140_img.gif",
                                                       "moduleinfor/sysframe/role/root.jsp",
                                                       this.getPri());
                        this.columnManager.save(roleColumn);
                        
                        Column postColumn = new Column(sysColumn,
                                                       "",
                                                       "岗位管理",
                                                       "column_13_img.gif",
                                                       "moduleinfor/sysframe/post/root.jsp",
                                                       this.getPri());
                        this.columnManager.save(postColumn);
                        
                        Column userColumn = new Column(sysColumn,
                                                       "",
                                                       "人员管理",
                                                       "column_245_img.gif",
                                                       "moduleinfor/sysframe/user/root.jsp",
                                                       this.getPri());
                        this.columnManager.save(userColumn);
                        
                        Column homeColumn = new Column(sysColumn,
                                                       "",
                                                       "主页管理",
                                                       "new_column_7.gif",
                                                       "moduleinfor/viewframe/home/root.jsp",
                                                       this.getPri());
                        this.columnManager.save(homeColumn);
                        
                        Column areaColumn = new Column(sysColumn,
                                                       "",
                                                       "分区管理",
                                                       "new_column_6.gif",
                                                       "moduleinfor/viewframe/area/root.jsp",
                                                       this.getPri());
                        this.columnManager.save(areaColumn);
                        
                        Column columnColumn = new Column(sysColumn,
                                                         "",
                                                         "栏目管理",
                                                         "GongWuSQ_01.gif",
                                                         "moduleinfor/viewframe/column/root.jsp",
                                                         this.getPri());
                        this.columnManager.save(columnColumn);
                        
                Column taskColumn = new Column(funcColumnsArea,
                                               "",
                                               "任务管理",
                                               "",
                                               this.getPri());
                this.columnManager.save(taskColumn);
                        Column taskRunningInfoColumn = new Column(taskColumn,
                                                                  "",
                                                                  "任务运行情况",
                                                                  "column_248_img.gif",
                                                                  "moduleinfor/system/taskrunninginfo/root.jsp",
                                                                  this.getPri());
                        this.columnManager.save(taskRunningInfoColumn);
                
                        
                
                // user角色 授权 个人事务
                userRole.addHome(defaultHome);
                userRole.addArea(funcColumnsArea);
                userRole.addColumn(moduleNameColumn);
                userRole.addColumn(examQuestionColumn);
                userRole.addColumn(personColumn);
                userRole.addColumn(changepwColumn);
                this.roleManager.update(userRole);
                
                // 管理员授权 日志管理,系统管理                
                hnnkzx_admin_post.addHome(defaultHome);
                hnnkzx_admin_post.addArea(funcColumnsArea);
                
                hnnkzx_admin_post.addColumn(basedataColumn);
                hnnkzx_admin_post.addColumn(typeColumn);
                
                hnnkzx_admin_post.addColumn(logColumn);
                hnnkzx_admin_post.addColumn(ologColumn);
                
                hnnkzx_admin_post.addColumn(sysColumn);
                hnnkzx_admin_post.addColumn(orgColumn);
                hnnkzx_admin_post.addColumn(roleColumn);
                hnnkzx_admin_post.addColumn(postColumn);
                hnnkzx_admin_post.addColumn(userColumn);
                hnnkzx_admin_post.addColumn(homeColumn);
                hnnkzx_admin_post.addColumn(areaColumn);
                hnnkzx_admin_post.addColumn(columnColumn);
                
                hnnkzx_admin_post.addColumn(taskColumn);
                hnnkzx_admin_post.addColumn(taskRunningInfoColumn);
                
                this.postManager.update(hnnkzx_admin_post);
                
                return admin; // 返回管理员
        }
        
        public void initBaseData(User admin)
        {
                Type root = new Type(null,TypeParams.ROOT,"  ",admin);
                root.setPri(this.getPri());
                this.typeManager.save(root);
                 
                // 领域
                Type domain = new Type(root,"domain","领域",admin);
                domain.setPri(this.getPri());
                this.typeManager.save(domain);
                
                Type langAndLetter = new Type(domain,DomainCode.LANG_AND_LETTER,"语言与文学",admin);
                langAndLetter.setPri(this.getPri());
                this.typeManager.save(langAndLetter);

                Type math = new Type(domain, DomainCode.MATH, "数学", admin);
                math.setPri(this.getPri());
                this.typeManager.save(math);

                Type science = new Type(domain, DomainCode.SICENCE, "科学", admin);
                science.setPri(this.getPri());
                this.typeManager.save(science);

                Type humanAndSociaty = new Type(domain,
                                                DomainCode.HUMAN_AND_SOCIATY,
                                                "人文与社会",
                                                admin);
                humanAndSociaty.setPri(this.getPri());
                this.typeManager.save(humanAndSociaty);

                Type gymAndLetter = new Type(domain,
                                             DomainCode.GYM_AND_ART,
                                             "体艺",
                                             admin);
                gymAndLetter.setPri(this.getPri());
                this.typeManager.save(gymAndLetter);

                Type technology = new Type(domain,
                                           DomainCode.TECHNOLOGY,
                                           "技术",
                                           admin);
                technology.setPri(this.getPri());
                this.typeManager.save(technology);
                
                // 学科
                Type chinese = new Type(langAndLetter,SubjectCode.CHINESE,"语文",admin);
                chinese.setPri(this.getPri());
                this.typeManager.save(chinese);    
                
                Type english = new Type(langAndLetter,SubjectCode.ENGLISH,"英语",admin);
                english.setPri(this.getPri());
                this.typeManager.save(english);    
                
                Type _math = new Type(math,SubjectCode.MATH,"数学",admin);
                _math.setPri(this.getPri());
                this.typeManager.save(_math);    
                
                Type physics = new Type(science,SubjectCode.PHYSICS,"物理",admin);
                physics.setPri(this.getPri());
                this.typeManager.save(physics);    
                
                Type chem = new Type(science,SubjectCode.CHEM,"化学",admin);
                chem.setPri(this.getPri());
                this.typeManager.save(chem);    
                
                Type biology = new Type(science,SubjectCode.BIOLOGY,"生物",admin);
                biology.setPri(this.getPri());
                this.typeManager.save(biology);

                // 课程
                Type chinese_BX_1 = new Type(chinese,SubjectCode.CHINESE+ "BX01","语文必修1",admin);
                chinese_BX_1.setPri(this.getPri());
                this.typeManager.save(chinese_BX_1);    
                
                Type chinese_BX_2 = new Type(chinese,SubjectCode.CHINESE+ "BX02","语文必修2",admin);
                chinese_BX_2.setPri(this.getPri());
                this.typeManager.save(chinese_BX_2);  
                
                Type chinese_xx_1 = new Type(chinese,SubjectCode.CHINESE+ "XX01","语文选修1",admin);
                chinese_xx_1.setPri(this.getPri());
                this.typeManager.save(chinese_xx_1);    
                
                Type chinese_xx_2 = new Type(chinese,SubjectCode.CHINESE+ "XX02","语文选修2",admin);
                chinese_xx_2.setPri(this.getPri());
                this.typeManager.save(chinese_xx_2);  
                
                Type chem_BX_1 = new Type(chem,SubjectCode.CHEM + "BX01","化学必修1",admin);
                chem_BX_1.setPri(this.getPri());
                this.typeManager.save(chem_BX_1);    

                Type chem_BX_2 = new Type(chem,SubjectCode.CHEM + "BX02","化学必修2",admin);
                chem_BX_2.setPri(this.getPri());
                this.typeManager.save(chem_BX_2);    
                
                Type chem_BX_3 = new Type(chem,SubjectCode.CHEM + "BX03","化学必修3",admin);
                chem_BX_3.setPri(this.getPri());
                this.typeManager.save(chem_BX_3);    
                
                Type chem_xx_1 = new Type(chem,SubjectCode.CHEM + "XX01","化学选修1",admin);
                chem_xx_1.setPri(this.getPri());
                this.typeManager.save(chem_xx_1);    
                
                Type chem_xx_2 = new Type(chem,SubjectCode.CHEM + "XX02","化学选修2",admin);
                chem_xx_2.setPri(this.getPri());
                this.typeManager.save(chem_xx_2);    
                  

                // 章
                // 语文
                Type chinese_BX_1_unit_1 = new Type(chinese_BX_1,SubjectCode.CHINESE+ "BX01" + "Z01","第1章",admin);
                chinese_BX_1_unit_1.setPri(this.getPri());
                this.typeManager.save(chinese_BX_1_unit_1); 

                Type chinese_BX_1_unit_2 = new Type(chinese_BX_2,SubjectCode.CHINESE+ "BX01" + "Z02","第1章",admin);
                chinese_BX_1_unit_2.setPri(this.getPri());
                this.typeManager.save(chinese_BX_1_unit_2); 
                
                Type chinese_xx_1_unit_1 = new Type(chinese_xx_1,SubjectCode.CHINESE+ "XX01" + "Z01","第1章",admin);
                chinese_xx_1_unit_1.setPri(this.getPri());
                this.typeManager.save(chinese_xx_1_unit_1);   
                                
                // 节
                Type chinese_BX_1_unit_1_se_1 = new Type(chinese_BX_1_unit_1,SubjectCode.CHINESE+ "BX01" + "Z01" + "J01","第１节",admin);
                chinese_BX_1_unit_1_se_1.setPri(this.getPri());
                this.typeManager.save(chinese_BX_1_unit_1_se_1); 

                Type chinese_BX_1_unit_2_se_1 = new Type(chinese_BX_1_unit_2,SubjectCode.CHINESE+ "BX01" + "Z02"  + "J02","第２节",admin);
                chinese_BX_1_unit_2_se_1.setPri(this.getPri());
                this.typeManager.save(chinese_BX_1_unit_2_se_1); 

                Type chinese_xx_1_unit_1_se_1 = new Type(chinese_xx_1_unit_1,SubjectCode.CHINESE+ "XX01" + "Z01" + "J01","第1节",admin);
                chinese_xx_1_unit_1_se_1.setPri(this.getPri());
                this.typeManager.save(chinese_xx_1_unit_1_se_1);
                
                // 知识点
                Type chinese_BX_1_unit_1_se_1_zsd_1_zsd_1 = new Type(chinese_BX_1_unit_1_se_1,SubjectCode.CHINESE+ "BX01" + "Z01" + "J01" + "ZSD1","知识点1",admin);
                chinese_BX_1_unit_1_se_1_zsd_1_zsd_1.setPri(this.getPri());
                this.typeManager.save(chinese_BX_1_unit_1_se_1_zsd_1_zsd_1); 

                Type chinese_BX_1_unit_2_se_1_zsd_1 = new Type(chinese_BX_1_unit_2_se_1,SubjectCode.CHINESE+ "BX01" + "Z02"  + "J02" + "ZSD2","知识点2",admin);
                chinese_BX_1_unit_2_se_1_zsd_1.setPri(this.getPri());
                this.typeManager.save(chinese_BX_1_unit_2_se_1_zsd_1); 
                
                Type chinese_xx_1_unit_1_se_1_zsd_1 = new Type(chinese_xx_1_unit_1_se_1,SubjectCode.CHINESE+ "XX01" + "Z01" + "J01" + "ZSD1","知识点1",admin);
                chinese_xx_1_unit_1_se_1_zsd_1.setPri(this.getPri());
                this.typeManager.save(chinese_xx_1_unit_1_se_1_zsd_1);   

                // 化学
                Type chem_BX_1_unit_1 = new Type(chem_BX_1,SubjectCode.CHEM+ "BX01" + "Z01","第1章",admin);
                chem_BX_1_unit_1.setPri(this.getPri());
                this.typeManager.save(chem_BX_1_unit_1); 

                Type chem_BX_1_unit_2 = new Type(chem_BX_2,SubjectCode.CHEM+ "BX01" + "Z02","第1章",admin);
                chem_BX_1_unit_2.setPri(this.getPri());
                this.typeManager.save(chem_BX_1_unit_2); 
                
                Type chem_xx_1_unit_1 = new Type(chem_xx_1,SubjectCode.CHEM+ "XX01" + "Z01","第1章",admin);
                chem_xx_1_unit_1.setPri(this.getPri());
                this.typeManager.save(chem_xx_1_unit_1);   
                                
                // 节
                Type chem_BX_1_unit_1_se_1 = new Type(chem_BX_1_unit_1,SubjectCode.CHEM+ "BX01" + "Z01" + "J01","第１节",admin);
                chem_BX_1_unit_1_se_1.setPri(this.getPri());
                this.typeManager.save(chem_BX_1_unit_1_se_1); 

                Type chem_BX_1_unit_2_se_1 = new Type(chem_BX_1_unit_2,SubjectCode.CHEM+ "BX01" + "Z02"  + "J02","第２节",admin);
                chem_BX_1_unit_2_se_1.setPri(this.getPri());
                this.typeManager.save(chem_BX_1_unit_2_se_1); 

                Type chem_xx_1_unit_1_se_1 = new Type(chem_xx_1_unit_1,SubjectCode.CHEM+ "XX01" + "Z01" + "J01","第1节",admin);
                chem_xx_1_unit_1_se_1.setPri(this.getPri());
                this.typeManager.save(chem_xx_1_unit_1_se_1);
                
                // 知识点
                Type chem_BX_1_unit_1_se_1_zsd_1_zsd_1 = new Type(chem_BX_1_unit_1_se_1,SubjectCode.CHEM+ "BX01" + "Z01" + "J01" + "ZSD1","知识点1",admin);
                chem_BX_1_unit_1_se_1_zsd_1_zsd_1.setPri(this.getPri());
                this.typeManager.save(chem_BX_1_unit_1_se_1_zsd_1_zsd_1); 

                Type chem_BX_1_unit_2_se_1_zsd_1 = new Type(chem_BX_1_unit_2_se_1,SubjectCode.CHEM+ "BX01" + "Z02"  + "J02" + "ZSD2","知识点2",admin);
                chem_BX_1_unit_2_se_1_zsd_1.setPri(this.getPri());
                this.typeManager.save(chem_BX_1_unit_2_se_1_zsd_1); 
                
                Type chem_xx_1_unit_1_se_1_zsd_1 = new Type(chem_xx_1_unit_1_se_1,SubjectCode.CHEM+ "XX01" + "Z01" + "J01" + "ZSD1","知识点1",admin);
                chem_xx_1_unit_1_se_1_zsd_1.setPri(this.getPri());
                this.typeManager.save(chem_xx_1_unit_1_se_1_zsd_1);
                
                // 难度
                Type difficulty = new Type(root,"difficulty","难易度",admin);
                difficulty.setPri(this.getPri());
                this.typeManager.save(difficulty);

                Type a = new Type(difficulty,DiffcultyCode.A,"A",admin);
                a.setPri(this.getPri());
                this.typeManager.save(a);

                Type b = new Type(difficulty,DiffcultyCode.B,"B",admin);
                b.setPri(this.getPri());
                this.typeManager.save(b);

                Type c = new Type(difficulty,DiffcultyCode.C,"C",admin);
                c.setPri(this.getPri());
                this.typeManager.save(c);
                
                Type d = new Type(difficulty,DiffcultyCode.D,"D",admin);
                d.setPri(this.getPri());
                this.typeManager.save(d);
                
                // 题目类型
                Type questionType = new Type(root,"questionType","题型",admin);
                questionType.setPri(this.getPri());
                this.typeManager.save(questionType);


                Type chinese_qt = new Type(questionType,SubjectCode.CHINESE + "_QT","语文题型",admin);
                chinese_qt.setPri(this.getPri());
                this.typeManager.save(chinese_qt);    
                        // 语文题型
                        Type ch_simpleSelect = new Type(chinese_qt,chinese_qt.getCode() + "_" + QuestionTypeCode.SIMPLE_SELECT,"单选题",admin);
                        ch_simpleSelect.setPri(this.getPri());
                        this.typeManager.save(ch_simpleSelect);

                        Type ch_multiSelect = new Type(chinese_qt,chinese_qt.getCode() + "_" + QuestionTypeCode.MULTI_SELECT,"多选题",admin);
                        ch_multiSelect.setPri(this.getPri());
                        this.typeManager.save(ch_multiSelect);
                        
                        Type ch_inputSelect = new Type(chinese_qt,chinese_qt.getCode() + "_" + QuestionTypeCode.INPUT,"填空题",admin);
                        ch_inputSelect.setPri(this.getPri());
                        this.typeManager.save(ch_inputSelect);
                        
                        Type ch_qaSelect = new Type(chinese_qt,chinese_qt.getCode() + "_" + QuestionTypeCode.Q_AND_A,"问答题",admin);
                        ch_qaSelect.setPri(this.getPri());
                        this.typeManager.save(ch_qaSelect);
                
                Type english_qt = new Type(questionType,SubjectCode.ENGLISH + "_QT","英语题型",admin);
                english_qt.setPri(this.getPri());
                this.typeManager.save(english_qt);    
                
                Type math_qt = new Type(questionType,SubjectCode.MATH + "_QT","数学题型",admin);
                math_qt.setPri(this.getPri());
                this.typeManager.save(math_qt);    
                
                Type physics_qt = new Type(questionType,SubjectCode.PHYSICS + "_QT","物理题型",admin);
                physics_qt.setPri(this.getPri());
                this.typeManager.save(physics_qt);    
                
                Type chem_qt = new Type(questionType,SubjectCode.CHEM + "_QT","化学题型",admin);
                chem_qt.setPri(this.getPri());
                this.typeManager.save(chem_qt);   
                        // 化学题型
                        Type simpleSelect = new Type(chem_qt,chem_qt.getCode() + "_" + QuestionTypeCode.SIMPLE_SELECT,"单选题",admin);
                        simpleSelect.setPri(this.getPri());
                        this.typeManager.save(simpleSelect);

                        Type multiSelect = new Type(chem_qt,chem_qt.getCode() + "_" + QuestionTypeCode.MULTI_SELECT,"多选题",admin);
                        multiSelect.setPri(this.getPri());
                        this.typeManager.save(multiSelect);
                        
                        Type inputSelect = new Type(chem_qt,chem_qt.getCode() + "_" + QuestionTypeCode.INPUT,"填空题",admin);
                        inputSelect.setPri(this.getPri());
                        this.typeManager.save(inputSelect);
                        
                        Type qaSelect = new Type(chem_qt,chem_qt.getCode() + "_" + QuestionTypeCode.Q_AND_A,"问答题",admin);
                        qaSelect.setPri(this.getPri());
                        this.typeManager.save(qaSelect);
                        
                Type biology_qt = new Type(questionType,SubjectCode.BIOLOGY + "_QT","生物题型",admin);
                biology_qt.setPri(this.getPri());
                this.typeManager.save(biology_qt);






                
                // 来源
                Type questionSource = new Type(root,"questionSource","考题来源",admin);
                questionSource.setPri(this.getPri());
                this.typeManager.save(questionSource);

                Type book = new Type(questionSource,QuestionSourceCode.BOOK,"课本",admin);
                book.setPri(this.getPri());
                this.typeManager.save(book);
                
                Type togetherExam = new Type(questionSource,QuestionSourceCode.TOGATHER_EXAM,"会考",admin);
                togetherExam.setPri(this.getPri());
                this.typeManager.save(togetherExam);	
                
                Type altExam = new Type(questionSource,QuestionSourceCode.ALT_EXAM,"高考",admin);
                altExam.setPri(this.getPri());
                this.typeManager.save(altExam);
                
                Type others = new Type(questionSource,QuestionSourceCode.OTHERS,"其他",admin);
                others.setPri(this.getPri());
                this.typeManager.save(others);
                
                
                
        }
}
